package com.csglxt.domain;

import java.math.BigDecimal;
import java.util.Date;
import java.util.HashSet;
import java.util.Set;

/**
 * 
 * @ClassName: Order
 * @Description: 订单实体类
 * @author Delver_Si
 * @date 2015-5-28 下午10:36:07
 * 
 */
@SuppressWarnings({ "unchecked", "serial", "rawtypes" })
public class Order implements java.io.Serializable {

    // Fields

    private String id;
    private Market market;
    private Supplier supplier;
    private Date date;
    private BigDecimal dealType;// 1上架 2下架 3 进货 4 退货
    private Set<OrderItem> orderItems = new HashSet<OrderItem>(0);

    // Constructors

    /** default constructor */
    public Order() {
    }

    /** full constructor */
    public Order(Market market, Supplier supplier, Date date,
            BigDecimal dealType, Set orderItems) {
        this.market = market;
        this.supplier = supplier;
        this.date = date;
        this.dealType = dealType;
        this.orderItems = orderItems;
    }

    // Property accessors

    public String getId() {
        return this.id;
    }

    public void setId(String id) {
        this.id = id;
    }

    public Market getMarket() {
        return this.market;
    }

    public void setMarket(Market market) {
        this.market = market;
    }

    public Supplier getSupplier() {
        return this.supplier;
    }

    public void setSupplier(Supplier supplier) {
        this.supplier = supplier;
    }

    public Date getDate() {
        return this.date;
    }

    public void setDate(Date date) {
        this.date = date;
    }

    public BigDecimal getDealType() {
        return this.dealType;
    }

    public void setDealType(BigDecimal dealType) {
        this.dealType = dealType;
    }

    public Set<OrderItem> getOrderItems() {
        return this.orderItems;
    }

    public void setOrderItems(Set<OrderItem> orderItems) {
        this.orderItems = orderItems;
    }

    public double getOrderzonge() {
        double zonge = 0.0;
        for (OrderItem item : orderItems) {
            zonge += item.getGoods().getPrice().multiply(item.getNumber())
                    .doubleValue();
        }
        return zonge;
    }

    @Override
    public String toString() {
        return "Order [id=" + id + ", market=" + market + ", supplier="
                + supplier + ", date=" + date + ", dealType=" + dealType
                + ", orderItems=" + orderItems + "]";
    }

}